<table data-options="fit:true" id="result_manager"></table>

<script>
	$(function(){ 
		$.post("../testServlet",{op:"getTest"},function(data){
			var sltObj=$("#result_tid");//获取下拉对象
			var opt;
			$.each(data.tidInfo,function(index,item){
				opt="<option value='"+item.tid+"'>"+item.tname+"</option>";
				sltObj.append($(opt));
			});
		},"json");
		var datagrid; 
		datagrid=$('#result_manager').datagrid({   
		    url:'../resultServlet',
		    queryParams:{op:"getAllResult"},
		    loadMsg:'数据加载中...',
		    pagination:true,
		    fitColumns:true,
		    rownumbers:true,
		    striped:true,
		    pageNumber:1,
		    sortOrder:'asc',
		    remoteSort:false,//定义是否通过远程服务器对数据排序。
		    sortName:'rid',
		    columns:[[
		    	{field:'rids',title:'',checkbox:true,width:100,align:'center'},   
		        {field:'rid',title:'编号',width:100,align:'center'},
		        {field:'tid',title:'关联测试',width:100,align:'center'},   
		        {field:'content',title:'结果',width:100,align:'center'},
		        {field:'condition',title:'条件',width:200,align:'center'}
		    ]],
		    toolbar: [{
		    	text:'添加',
				iconCls: 'icon-add',
				handler: function(){
					$("#add_result").dialog("open");
				}
			},'-',{
				text:'删除',
				iconCls: 'icon-remove',
				handler: function(){
						
				}
			}]   
		});
  
	});
</script>

<div id="add_result" class="easyui-dialog" title="添加结果" style="width:800px;height:600px"
	data-options="iconCls:'icon-add',resizeble:true,modal:true,closed:true">
	<br /><br />
	<form action="" style="float:left;padding-left:20px" id="resultInfo" name="resultInfo" method="post">
		<p><label>关联测试:</label>
			<select id="result_tid" name="tid"></select>
		</p>
		<p><label style="vertical-align: top">测试结果:</label>
			<textarea cols="100" rows="3" id="result_content" name="content"></textarea>
		</p>
		<p><label>结果条件:</label><input type="text" id="result_condition" name="condition" style="width:200px;"></p>
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addRuselt()" style="margin-left:60px;">添加</a>			
	</form>
</div>

<script>
	function addRuselt(){
		var tid=$("#result_tid").val();
		var	content=$("#result_content").val();
		var condition=$("#result_condition").val();
		$.post("../resultServlet",{op:"addResult",tid:tid,content:content,condition:condition},function(data){
			data=parseInt($.trim(data));
				if(data==1){
					$.messager.show({
						title:'成功提示',
						msg:'测试添加成功...',
						timeout:3000,
						showType:'slide'
					});
					$('#add_result').dialog("close");
					$('#result_manager').datagrid("reload");
					$("#resultInfo")[0].reset();
				}else{
					$.messager.alert('错误提示','测试添加失败,请稍后重试...','error');
				}
		});
	}
</script>